const {http ,handleStr} = require("../../utils/index")
Page({
    data:{
        musics:[]
    },
    onLoad(){
        var url = "http://47.108.197.28:3000/top/playlist?cat=%E5%8D%8E%E8%AF%AD"
        http({
            url,
            success:result=>{
                this.handleHttpData(result) 
            }
        })
    },
    handleHttpData(result){
            var musics = []
            var playlists = result.data.playlists;
                playlists.forEach(item=>{
                    var {id,name,coverImgUrl} = item
                    musics.push(
                    {   id,
                        name : handleStr(name),
                        coverImgUrl
                    }
                    )
                })
                // console.log(musics);
                this.setData({
                    musics,
                })
    },
    handleItem(event){
        console.log(event);
        var {aid} = event.currentTarget.dataset;
        wx.navigateTo({
            url: `/pages/detail/detail?id=${aid}`
        });
    }
})